package com.rpj.stauy.controller;

import dev.langchain4j.model.chat.ChatModel;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("langchain")
public class HelloLangChain4jController {

    @Resource
    private ChatModel chatModel;

    //http://localhost:9090/langchain/hello
    @GetMapping("/hello")
    public String HelloWorld(@RequestParam(value = "prompt",defaultValue = "你是谁") String prompt){
        return chatModel.chat(prompt);
    }
}
